package com.heer.gymnasium.module.coach.views;

import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import com.heer.amap.utils.ToastUtil;
import com.heer.gymnasium.R;
import com.heer.gymnasium.api.ResponseData.ApiResponse;
import com.heer.gymnasium.api.callback.BaseCallback;
import com.heer.gymnasium.base.BaseActivity;
import com.heer.gymnasium.base.BaseRefreshActivity;
import com.heer.gymnasium.module.login.views.LoginActivity;
import com.heer.gymnasium.module.my.views.FaceActivity;
import com.heer.gymnasium.util.Base64Util;
import com.heer.gymnasium.util.SDCardUtils;
import com.heer.imagepick.DensityUtils;
import com.zhihuiyun.library.utils.BitmapUtils;

import java.io.File;

import butterknife.BindView;
import retrofit2.Call;
import retrofit2.Response;

/**
 * 私教权限
 * Created by zy on 2018/2/26.
 */

public class CoachAuthorityActivity extends BaseRefreshActivity {
    private final static int RES_ID_ROOT = R.layout.layout_coach_list;
    private final static int RES_ID_MENU_LIST = R.id.layout_coach_list_lv;

    private static final int RES_ID_ITEM_LAYOUT = android.R.layout.simple_dropdown_item_1line;


    private int d5, d10, d15;

    private final static String[] MENU = new String[]{
            "私教核销",
            "私教订课",
            "私教统计",
    };

    @BindView(RES_ID_MENU_LIST)
    ListView listView;

    private CoachAuthorityActivity $this;

    @Override
    protected void init() {
        super.init();
        $this = this;
        d5 = DensityUtils.dip2px($this, 5);
        d10 = d5 * 2;
        d15 = d5 * 3;
        setContentView(RES_ID_ROOT);
        setRefreshResId(RES_ID_REFRESH_LAYOUT);
    }

    @Override
    protected void initView() {
        super.initView();
        titleUtils.startMainActivity(this);
        listView.setPadding(0, 0, 0, 0);
        listView.setAdapter(new ArrayAdapter<String>($this, RES_ID_ITEM_LAYOUT, MENU) {
            @NonNull
            @Override
            public View getView(final int position, @Nullable View convertView, @NonNull ViewGroup parent) {
                if (convertView == null) {
                    convertView = LayoutInflater.from(getContext()).inflate(RES_ID_ITEM_LAYOUT, null);
                }
                TextView tv = (TextView) convertView;
                tv.setText(MENU[position]);
                tv.setPadding(d15, d15, d15, d15);
                tv.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        switch (position) {
                            case 0:
                                CoachVerificationActivity.startActivity($this);
                                break;
                            case 1:
                                CoachCourseActivity.startActvity($this);
                                break;
                            case 2:
                                CoachStatisticsActivity.startActivity($this);
                                break;
                        }
                    }
                });
                return tv;
            }
        });
    }


    @Override
    protected void loadData(boolean loadMore) {
        super.loadData(loadMore);
        layoutRefresh.setRefreshing(false);
    }

    public static void startActivity(Context context) {
        Intent intent = new Intent(context, CoachAuthorityActivity.class);
        context.startActivity(intent);
    }
}
